package auth

import (
	"GraduationProject/webserver/status"
	"github.com/gin-gonic/contrib/sessions"
	"github.com/gin-gonic/gin"
	"net/http"
)

func Logout(ctx *gin.Context) {
	session := sessions.Default(ctx)
	session.Delete("user")
	session.Delete("admin")
	if err := session.Save(); err != nil {
		ctx.JSON(http.StatusOK, gin.H{
			"status":  status.UnknownError,
			"message": "未知错误",
		})
	}

	ctx.JSON(http.StatusOK, gin.H{
		"status":  10000,
		"message": "success",
	})
}
